Skip to content

test(invariants): add TIP-1016 state gas invariant tests and update GasPricing/BlockGasLimits for gas dimension split#3369

Open
fgimenez wants to merge 5 commits intotip1016from
fgimenez/tip1016-invariants
Open

test(invariants): add TIP-1016 state gas invariant tests and update GasPricing/BlockGasLimits for gas dimension split#3369
fgimenez wants to merge 5 commits intotip1016from
fgimenez/tip1016-invariants

Conversation

@fgimenez
Copy link
Copy Markdown
Member

Updates existing invariant tests and adds new ones for TIP-1016's gas dimension split (regular vs state gas).

GasPricing.t.sol: Fixed handler_multipleNewSlots which was broken post-TIP-1016 — only 20k regular gas per SSTORE counts against limits, so the old "gas for 1 slot" threshold no longer caused N>1 to fail. Added state gas tracking ghost variables.

BlockGasLimits.t.sol: Reworked tx gas cap enforcement — tx.gas > cap is now valid when excess is state gas. Updated deployment gas calculation to split regular/state components so tx.gas can exceed the cap for large contracts.

TIP1016.t.sol: New test covering 12 invariants across gas dimension split (GAS1-3), reservoir model (RES1-3), block accounting (BLK1-3), and refund semantics (REF1-2).

@fgimenez fgimenez added C-test A change that impacts how or what we test A-precompile Related to precompiles labels Mar 30, 2026
@fgimenez fgimenez force-pushed the fgimenez/tip1016-invariants branch from 13cb3cb to ad57193 Compare March 30, 2026 14:13
@fgimenez fgimenez force-pushed the fgimenez/tip1016-invariants branch from ad57193 to b3b1583 Compare April 7, 2026 10:51
@fgimenez fgimenez force-pushed the fgimenez/tip1016-invariants branch from b3b1583 to e43a08b Compare April 7, 2026 16:20
@fgimenez fgimenez force-pushed the fgimenez/tip1016-invariants branch from e43a08b to 1362a4d Compare April 8, 2026 08:18
@fgimenez fgimenez force-pushed the tip1016 branch 2 times, most recently from 6b8da60 to 630ee48 Compare April 8, 2026 11:52
@fgimenez fgimenez force-pushed the fgimenez/tip1016-invariants branch from 6b913a8 to 6e44bac Compare April 8, 2026 14:54
@fgimenez fgimenez force-pushed the tip1016 branch 2 times, most recently from a26c48c to 0ebd6ce Compare April 9, 2026 15:53
@fgimenez fgimenez force-pushed the fgimenez/tip1016-invariants branch from cea400d to cb20d9d Compare April 9, 2026 17:06
fgimenez and others added 5 commits April 9, 2026 17:17
…asPricing/BlockGasLimits for gas dimension split
The invariant-tests workflow injects wrapper functions before the last
closing brace in each file. With helpers at the bottom, the wrappers
ended up inside the helper contract instead of the test contract.

Co-Authored-By: Federico Gimenez <70376+fgimenez@users.noreply.github.com>
The invariant-tests workflow injects wrapper functions before every
'^}$' line in the test file. With helpers inline, the wrappers got
injected into helper contracts too. Moved GasTestStorage, TIP1016Storage,
and GasLeftChecker to test/helpers/.

Co-Authored-By: Federico Gimenez <70376+fgimenez@users.noreply.github.com>
Under TIP-1016, state gas is exempt from tx/block limits and comes from
the reservoir. Operations like SSTORE only cost 20k regular gas (vs 250k
total), so the old 'insufficient gas' thresholds (100k, 200k) are now
sufficient. Use gas below intrinsic tx cost to guarantee failure.

For RES1, use tx.gas = MAX_TX_GAS_LIMIT (not above) since the reservoir
model isn't fully active in foundry's EVM runtime.

Co-Authored-By: Federico Gimenez <70376+fgimenez@users.noreply.github.com>
@fgimenez fgimenez force-pushed the fgimenez/tip1016-invariants branch from cb20d9d to 128a80b Compare April 9, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-precompile Related to precompiles C-test A change that impacts how or what we test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants